var onlineRecordCtrl  = new XFApp.client();
$.views.converters({
	
	fauditStatus : function(value) {
		
		if(!value){
			return "";
		}
		for(index in auditStates){
			var auditState = auditStates[index];
			if(auditState.dictCode == value){
				return auditState.dictName;
			}
		}
		return  "未知类型("+value+")";
	},	
	
});

XFApp.client.prototype.onlineRecord = {
		successCode : "10000",	
		onlineRecordPage : null,
		urlItems : {
			initListURL: basePath+"/userCenter/enOnlineRecord/init",
			delRecordURL: basePath+"/userCenter/enOnlineRecord/delRecord",
		},
		
		delRecord:function(id){
			
			 var type = $("#delRecord").attr("title");
			
			 webAlert({
	                title:'提示',
	                content:'确认执行'+type+'操作吗?',
	                opacity:.5,
	                bg:"gray",
	                width:300,
	                height:10,
	                button:[
	                        {
	                        name:"确定",
	                        callback:function(){
	                        	_this.delConfirm(id);
	                        	this.close();
	                        }
	                        },{
	                        name:"取消",
	                        callback:function(){
	                      	  this.close();
	                        }
	                        }]
	             });
		},
		
		delConfirm: function(id){
			
			var params = {	
            		id : id 				
			}
	    	
	    	$.ajax({
	    		url :_this.urlItems.delRecordURL,
	    		data : params,
	    		dataType : "json",
	    		type : 'post',
	    		success : function(data) {				
	    			if(data.code==_this.successCode){ 
	    				window.webDialogUtil.alert("提示","删除成功");	    				
	    				//刷新
	    				_this.load();	    				
				    	        		
	    			}else{
	    				window.webDialogUtil.alert("提示",data.msg);
	    			}
	    		}
	    	});			
			
		},
		
		event : function (){			
			_this = this;
			$("#searchButton").on("click",function(){
				_this.load();
			});
		},	
		
		load : function (){		
            _this = this;
            onlineRecordVo = {
            		companyName : $("#companyName").val()
    		};
			if(!!_this.onlineRecordPage){
				_this.onlineRecordPage.page("remote",0,onlineRecordVo);
			}else{
				_this.onlineRecordPage = $("#page").page({
				pageSize : 10,
				remote: {
					url: _this.urlItems.initListURL,
			        params: onlineRecordVo, 
			        success: function (data, pageIndex) {
			        	if(data.code==_this.successCode){
			        		if(null == data.result 
										|| null == data.result.itemList
											|| data.result.itemList.length < 1){
			        			$("#page_grid").html('<tr><td align="center" colspan="11">暂无数据</td></tr>');
			        		}else{
			        			$("#page_grid").html($("#pageTmp").render(data.result.itemList));
			        		}
			        	}else{
			        		  window.webDialogUtil.alert("提示","数据查询失败!");
			        	}
			        },
			        error : function(){
			        	window.webDialogUtil.alert("提示","数据查询失败!");
			        }
				},
				firstBtnText : '首页',
				lastBtnText : '尾页',
				prevBtnText : '上一页',
				nextBtnText : '下一页',
				showInfo : true,
				showJump : true,
				jumpBtnText : '跳转',
				showPageSizes : true,
				infoFormat : '共{pageCount}页'
			});	
		   }			
		},
		
},

$(function(){	
	onlineRecordCtrl.onlineRecord.load();
	onlineRecordCtrl.onlineRecord.event();
	
});